<template>
	<view>
		<view class="navigation">
			<view class="navigation_back" @tap="backref()">
				<uni-icons type="back" size="24" color="#fff"></uni-icons>
			</view>
			<view class="navigation_title">
				外卖
			</view>
		</view>
		<view class="shop_con">
			<view class="shop_con_search">
				<image src="../../static/image/shop/search.svg" mode=""></image>
				<input type="text" placeholder="请输入内容">
			</view>
			<view class="shop_con_situtaions">
				<view class="shop_con_situtaion" v-for="(item,index) in situtaion" :key="index" :class="item.order_by!=''?'active':''" @tap="changeSitutaion(item)">
					{{item.name}}
					<view class="shop_con_situtaion_arrow" :class="item.order_by=='asc'?'active':''" v-if="item.order_by != ''">
						<uni-icons type="bottom" size="15" color="#2588FF"></uni-icons>
					</view>
				</view>
			</view>
			<view class="shop_list">
				<view class="shop_item" v-for="(item,index) in shopList" :key="index" @tap="toShopDetail(item)">
					<view class="shop_item_img">
						<image :src="item.picUrl" mode="aspectFill"></image>
					</view>
					<view class="shop_item_info">
						<view class="shop_item_title">
							{{item.title}}
						</view>
						<view class="shop_item_bd">
							<view class="shop_item_score">
								{{item.score}}分
							</view>
							<view class="shop_item_sale">
								月销{{item.sale}}
							</view>
						</view>
						<view class="shop_item_bt">
							<view class="shop_item_price">
								起送¥{{item.price}}
							</view>
							<view class="shop_item_distribution">
								配送
								{{item.distribute}}
							</view>
						</view>
						<view class="shop_item_distance">
							{{item.distance}}m
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				situtaion:[
					{
						name:'综合排序',
						order_by:'desc'
					},
					{
						name:'销量',
						order_by:''
					},
					{
						name:'星级',
						order_by:''
					},
					{
						name:'距离',
						order_by:''
					},
				],
				shopList:[
					{
						picUrl:require('../../static/image/shop/shop_01.jpg'),
						title:'麻辣酸菜鱼店',
						score:'4.9',
						sale:401,
						price:'17',
						distribute:'3',
						distance:'400'
					},
					{
						picUrl:require('../../static/image/shop/shop_02.jpg'),
						title:'张亮麻辣烫',
						score:'4.9',
						sale:401,
						price:'17',
						distribute:'3',
						distance:'400'
					},
					{
						picUrl:require('../../static/image/shop/shop_03.jpg'),
						title:'黄焖鸡店',
						score:'4.9',
						sale:401,
						price:'17',
						distribute:'3',
						distance:'400'
					},
					{
						picUrl:require('../../static/image/shop/shop_04.jpg'),
						title:'古法秘制烤鸭店',
						score:'4.9',
						sale:401,
						price:'17',
						distribute:'3',
						distance:'400'
					},
					{
						picUrl:require('../../static/image/shop/shop_01.jpg'),
						title:'麻辣酸菜鱼店',
						score:'4.9',
						sale:401,
						price:'17',
						distribute:'3',
						distance:'400'
					},
					{
						picUrl:require('../../static/image/shop/shop_02.jpg'),
						title:'张亮麻辣烫',
						score:'4.9',
						sale:401,
						price:'17',
						distribute:'3',
						distance:'400'
					},
				]
			};
		},
		methods:{
			changeSitutaion(item){
				if(item.order_by == ''){
					item.order_by = 'desc'
				}else if(item.order_by == 'desc'){
					item.order_by = 'asc'
				}else{
					item.order_by = 'desc'
				}
			},
			toShopDetail(item){
				uni.navigateTo({
					url:'/pages/shop/detail'
				})
			}
		}
	}
</script>

<style lang="scss">
	.navigation {
		width: 100%;
		height: 180rpx;
		background-color: #2588FF;
		padding: 60rpx 24rpx 0;
		text-align: center;
		position: relative;

		.navigation_back {
			position: absolute;
			top: 60rpx;
		}

		.navigation_title {
			color: #fff;
			font-size: 36rpx;
		}
	}
	.shop_con{
		position: relative;
		z-index: 2;
		padding: 40rpx 32rpx 180rpx;
		border-radius: 32rpx 32rpx 0 0;
		background-color: #fff;
		margin-top: -30rpx;
		.shop_con_search{
			width: 100%;
			height: 90rpx;
			border-radius: 90rpx;
			background-color: #f8f8f8;
			padding: 0 24rpx;
			display: flex;
			align-items: center;
			image{
				width: 36rpx;
				height: 36rpx;
			}
			input{
				margin-left: 24rpx;
				width: 70%;
				font-size: 28rpx;
				color: #333;
				&.placeholder{
					color: #C3C3C3;
				}
			}
		}
		.shop_con_situtaions{
			display:flex;
			align-items: center;
			margin-top: 24rpx;
			.shop_con_situtaion{
				display: flex;
				align-items: center;
				color: #333;
				font-size: 26rpx;
				margin-right: 48rpx;
				&.active{
					color: #2588FF;
				}
				.shop_con_situtaion_arrow{
					margin-left: 6rpx;
					&.active{
						transform: rotate(180deg);
					}
				}
			}
		}
		.shop_list{
			margin-top: 24rpx;
			.shop_item{
				position: relative;
				display: flex;
				margin-bottom: 24rpx;
				.shop_item_img{
					width: 130rpx;
					height: 130rpx;
					flex-shrink: 0;
					image{
						width: 100%;
						height: 100%;
						border-radius: 12rpx;
					}
				}
				.shop_item_info{
					margin-left: 24rpx;
					.shop_item_title{
						font-size: 28rpx;
						color: #2E343A;
						font-weight: 700;
					}
					.shop_item_bd{
						display: flex;
						align-items: center;
						margin-top: 6rpx;
						.shop_item_score{
							color: #2588FF;
							font-size: 26rpx;
						}
						.shop_item_sale{
							font-size: 26rpx;
							color: #9098A0;
							margin-left: 12rpx;
						}
					}
					.shop_item_bt{
						display: flex;
						align-items: center;
						margin-top: 8rpx;
						.shop_item_price{
							color: #9098A0;
							font-size: 26rpx;
						}
						.shop_item_distribution{
							font-size: 26rpx;
							color: #9098A0;
							margin-left: 12rpx;
						}
					}
					.shop_item_distance{
						position: absolute;
						right: 0;
						bottom: 0;
						font-size: 24rpx;
						color: #666;
					}
				}
			}
		}
	}
</style>